
<#include "header.html">

<div class="container">
    <div class="section">


        <div class="row">
            <div class="col s12 l9">




                <div class="row">
                    <div class="col s12 m12">
                        <div class="card hoverable">



                            <ul class="collection">
                                <li class="collection-item ">

                                    <a href="/user/${thisUser.id}"><img height="80" src="${thisUser.headUrl}" alt="" class="circle secondary-content"></a>
                                    <a href=""><span class="title"><h5>${post.title}</h5></span></a>

                                    <p class="thin">

                                        <a href="/user/${thisUser.id}">${thisUser.name}</a>  •  创建于 ${post.createdDate?datetime}
                                    </p>



                                </li>
                                <li class="collection-item ">
                                    <p>${post.content}</p>

                                </li>
                                <li class="collection-item ">
                                    <a href="javascript:$.post('/like',{postId:${post.id}}, function(data){$('#like-btn').html(JSON.parse(data).msg);});" class="waves-effect waves-light btn-small"><i class="material-icons right">thumb_up</i><span id="like-btn">${likeCount}</span></a>
                                    <a href="javascript:$.post('/dislike',{postId:${post.id}}, function(data){$('#like-btn').html(JSON.parse(data).msg);});" class="waves-effect waves-light btn-small"><i class="material-icons right">thumb_down</i></a>


                                    <a href="javascript:$('#entity_id').val(${post.id});$('#entity_type').val(1);$('#modal2').modal('open');" class="modal-trigger waves-effect waves-light secondary-content">回复</a>

                                </li>

                            </ul>



                        </div>
                    </div>
                </div>



                <div class="row">
                    <div class="col s12 m12">
                        <div class="card hoverable">

                            <div class="card-action">
                                ${post.commentCount} 条回复
                            </div>

                            <ul class="collection">

                                <#list comments as vo>
                                    <li class="collection-item avatar">
                                        <a href="/user/${vo.user.id}"><img src="${vo.user.headUrl}" alt="" class="circle"></a>

                                        <p class=""><a href="/user/${vo.user.id}">${vo.user.name}</a>  <span class="thin">创建于 ${vo.comment.createdDate?datetime}</span>
                                            <#if user?? && user.id == vo.user.id>
                                            •
                                            <a href="javascript:$.post('/comment/remove',{id:${vo.comment.id}, post_id:${post.id}}, function(data){console.log(data);window.location.reload();});" class="modal-action modal-close waves-effect  "> 删除</a>
                                        </#if>
                                        </p>
                                        <a href="javascript:$('#entity_id').val(${vo.comment.id});$('#entity_type').val(2);$('#modal2').modal('open');" class="modal-trigger waves-effect waves-light secondary-content">回复</a>


                                        <#if vo.replyUser??>
                                        <p class="">@<a href="/user/${vo.replyUser.id}">${vo.replyUser.name}</a></p>
                                        </#if>
                                        <p>${vo.comment.content}</p>

                                    </li>
                                </#list>



                            </ul>


                            <!-- Modal Structure -->
                            <div id="modal2" class="modal modal-fixed-footer">
                                <div class="modal-content">



                                    <div class="row">
                                        <form id="reply-form" action="/comment/add" method="post" class="col s12">

                                            <input type="hidden" id="entity_id" name="entity_id" value=${post.id}>
                                            <input type="hidden" id="entity_type" name="entity_type" value=1>
                                            <input type="hidden" id="post_id" name="post_id" value=${post.id}>


                                            <div class="row">
                                                <div class="input-field col s12">
                                                    <textarea name="content" id="textarea1" class="materialize-textarea" length="1000"></textarea>
                                                    <label for="textarea1">内容</label>
                                                </div>
                                            </div>
                                        </form>
                                    </div>
                                </div>
                                <div class="modal-footer">
                                    <a href="javascript:$('#reply-form').submit();" class="modal-action modal-close waves-effect btn  ">回复</a>
                                    <a href="#!" class="modal-action modal-close waves-effect btn-flat ">取消</a>
                                </div>
                            </div>






                        </div>
                    </div>
                </div>



            </div>


        </div>


    </div>

</div>

<#include "footer.html">